﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Coder.Workflow.Mapping
{
    public class WorkActivityMapping : IEntityTypeConfiguration<WorkActivity>
    {
        public void Configure(EntityTypeBuilder<WorkActivity> builder)
        {
            builder.HasKey(_ => _.Id);
            builder.Property(_ => _.Id).ValueGeneratedOnAdd();
            // builder.Property(_ => _.Name).HasMaxLength(24);

            builder.HasOne(_ => _.Role);
            builder.HasOne(_ => _.WorkTask);
            builder.Property(_ => _.Status);
            builder.Property(_ => _.Comment).HasMaxLength(256);
            builder.HasOne(_ => _.DepositUser);

            builder.Property(_ => _.DepositTime);
            builder.Property(_ => _.AssignTime);

            builder.Property(_ => _.CreateTime).ValueGeneratedOnAdd().HasDefaultValueSql("'0001-00-00 00:00:00'");

            builder.Property(f => f.TimeSpan)
                .ValueGeneratedOnAddOrUpdate().IsConcurrencyToken();
        }
    }
}